import React, { Component } from 'react';
import { Table, Pagination} from 'antd';
import styles from './TableList.less'

const payType = (item) => {
  if(item == 1){
    return '支付宝'
  }else if(item == 2){
    return '现金'
  }else if(item == 3){
    return '微信'
  }
}

const columns = [
  // {
  // title: '序号',
  // dataIndex: 'number',
  // key: '1',
  // width:"5%"
  // },
  {
    title: '会员名称',
    dataIndex: 'name',
    key: '2',
    width:"20%"
  },
  {
    title: '充值时间',
    dataIndex: 'createTime',
    key: '3',
    width:"20%"
  },
  {
    title: '充值金额',
    dataIndex: 'money',
    key: '4',
    width:"20%",
    render:(text) =>{
      return(
        <span>{text ? text : "0"}</span>
      )
    }
  },
  {
    title: '赠送积分',
    dataIndex: 'bonouse',
    key: '5',
    width:"20%",
    render:(text) =>{
      return(
        <span>{text ? text : "0"}</span>
      )
    }
  },
  {
    title: '支付方式',
    dataIndex: 'payType',
    key: 'payType',
    width:"15%",
    render:(text)=>payType(text),
  },
];



class TableList extends Component {


  render() {
    const { RehargeItem ,loading} = this.props
    const { list , totalElements} = RehargeItem
    return (
      <div className={styles.charge_list}>
        <div className={styles.TableList}>
          <Table bordered
            rowKey={record => record.id}
           columns={columns}
           dataSource={list}
           loading={loading}
           pagination ={false}/>
         </div>
         <div className={styles.pagesize}>
           <Pagination defaultCurrent={1} onChange={this.props.onHandlePage} total={totalElements ? Number(totalElements) : 1} />
         </div>
      </div>

    );
  }
}

export default TableList;
